angular.module('app').config(function ($stateProvider) {

    $stateProvider.state('app.vibration', {
        url         : '/vibration',
        label       : '震动',
        controller  : 'app.vibration',
        controllerAs: '$ctrl',
        templateUrl : 'view/app/vibration/vibration.html'
    });
}).controller('app.vibration', function ($ionicPlatform) {
    var ctrl = this;
    
    $ionicPlatform.ready(function () {
        ctrl.vibrate = function () {
            /**
             * navigator.vibrate(time) or navigator.vibrate([time])
             * 震动多长时间(毫秒)
             * Android & Windows
             * - navigator.vibrate([1000, 1000, 3000, 1000, 5000]); 表示震动 1s 然后等待 1s 再震动 3s 然后再等待 1s 最后再震动 5s
             */
            navigator.vibrate(3000);
        };

        ctrl.cancelVibrate = function () {
            /**
             * navigator.vibrate(0) or navigator.vibrate([]) or navigator.vibrate([0])
             * 取消震动(iOS 不支持)
             */
            navigator.vibrate(0);
        };
    });
});